package com.healer.IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class TestFileInputStream {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("src/main/resources/test.txt");

        //1、 单字节读取
//        int data = 0;
//        while((data=fis.read())!=-1){//如果没有内容就会读到-1
//            System.out.println((char)data);
//        }

        //2、 多字节读取
        int data1=0;//读取的字符长度
        byte[] buf = new byte[3];
        while ((data1=fis.read(buf))!=-1){
            System.out.println(new String(buf,0,data1));
        }
        fis.close();
    }
}
